/*
 * Copyright [vega-ai-sdk] [rightbrain.art]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * According to vega feature, we modify some class，comment, field name, etc.
 */

package com.rightbrain.vegaai.tool.sdk.exception;

import com.rightbrain.vegaai.tool.sdk.common.ResourceCode;
import org.springframework.util.StringUtils;


public class VegaAIException extends RuntimeException {

    private ResourceCode resourceCode = ResourceCode.INTERNAL_SERVER_ERROR;

    public VegaAIException() {
        super();
    }

    public VegaAIException(String message) {
        super(message);
    }

    public VegaAIException(String message, Throwable cause) {
        super(message, cause);
    }

    public VegaAIException(Throwable cause) {
        super(cause);
    }

    public VegaAIException(ResourceCode resourceCode) {
        this(resourceCode.message());
        this.resourceCode = resourceCode;
    }

    public VegaAIException(ResourceCode resourceCode, String message) {
        this(StringUtils.hasText(message) ? message : resourceCode.message());
        this.resourceCode = resourceCode;
    }

    public VegaAIException(ResourceCode resourceCode, Throwable cause) {
        this(resourceCode.message(), cause);
        this.resourceCode = resourceCode;
    }

    public VegaAIException(ResourceCode resourceCode, String message, Throwable cause) {
        this(resourceCode, StringUtils.hasText(message) ? message : resourceCode.message());
        this.initCause(cause);
    }

    public ResourceCode getResourceCode() {
        return resourceCode;
    }

}
